from appium import webdriver

desired_caps = dict()
desired_caps['platformName'] = 'Android'
desired_caps['platformVersion'] = '5.1'
desired_caps['deviceName'] = '192.168.56.101:5555'
desired_caps['appPackage'] = 'com.android.settings'
desired_caps['appActivity'] = '.Settings'

# 解决中文问题
desired_caps['unicodeKeyboard'] = True
desired_caps['resetKeyboard'] = True

driver = webdriver.Remote('http://192.168.41.103:4723/wd/hub', desired_caps)

eles = driver.find_elements_by_class_name("android.widget.TextView")
for i in eles:
    print(i.text)
    # print(i.size)
    # print(i.location)
    # print(i.get_attribute("text"))
    #
    # print(i.get_attribute("resourceId"))
    # print(i.get_attribute("className"))
    print(i.get_attribute("name"))

    print("----")


# driver.find_element_by_id("com.android.settings:id/search").click()
# driver.find_element_by_class_name("android.widget.EditText").send_keys("你好")
# driver.find_element_by_xpath("//*[@content-desc='收起']").click()
